<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Index extends Site_Controller
{
  function __construct()
  {
    parent::__construct();
    $this->load->model('mod_index', 'md');
  }
  
  public function view()
  {
    $this->q = $q = $this->input->get('q');
    $uriSegment = 2;
    $perPage = 20;
    $this->data = $this->md->getLatestAds(uri($uriSegment), $perPage, $q);
    pagination_config(site_url('home'), $this->md->getLatestAdsNum($q), $perPage, $uriSegment); // base_url, total_num, per_page, segment
    
    $this->category = $this->md->getCategory();
    $this->title  = 'Home';
  }
  
  public function detail()
  {
    $id = uri(2);
    $this->row = $this->md->getAdsById($id);
      
    $this->title  = 'Ads Detail';
    $this->action = 'Ads Detail';
  }
}